﻿Namespace DotNetNuke.Modules.ActiveForums.Helpers
    Public Class SettingConversion
        Public Function MoveSettings(ForumModuleId As Integer, TabModuleId As Integer) As Boolean
            Dim objModules As New Entities.Modules.ModuleController()
            Dim currSettings As New SettingsInfo
            currSettings.MainSettings = Settings.GeneralSettings(ForumModuleId, "GEN")

            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PageSize, currSettings.PageSize.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.UserNameDisplay, currSettings.UserNameDisplay)
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.ProfileType, CInt(currSettings.ProfileType).ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.EnablePoints, currSettings.EnablePoints.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.TopicPointValue, currSettings.TopicPointValue.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.ReplyPointValue, currSettings.ReplyPointValue.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.AnswerPointValue, currSettings.AnswerPointValue.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.MarkAnswerPointValue, currSettings.MarkAsAnswerPointValue.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.ModPointValue, currSettings.ModPointValue.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.AvatarHeight, currSettings.AvatarHeight.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.AvatarWidth, currSettings.AvatarWidth.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.AllowSignatures, currSettings.AllowSignatures.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.ForumTemplateId, currSettings.ForumTemplateID.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.InstallDate, currSettings.InstallDate.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.IsInstalled, currSettings.IsInstalled.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.Theme, currSettings.Theme.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.FullText, currSettings.FullText.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.MailQueue, currSettings.MailQueue.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.FloodInterval, currSettings.FloodInterval.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.EditInterval, currSettings.EditInterval.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.DeleteBehavior, currSettings.DeleteBehavior.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.AddThisAccount, currSettings.AddThisAccount.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.EnableAutoLink, currSettings.AutoLinkEnabled.ToString())
            objModules.UpdateModuleSetting(TabModuleId, SettingKeys.EnableURLRewriter, currSettings.URLRewriteEnabled.ToString())
            If String.IsNullOrEmpty(currSettings.PrefixURLBase) Then
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLBase, "forums")
            Else
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLBase, currSettings.PrefixURLBase.ToString())
            End If
            If String.IsNullOrEmpty(currSettings.PrefixURLOther) Then
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLOther, "views")
            Else
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLOther, currSettings.PrefixURLOther.ToString())
            End If
            If String.IsNullOrEmpty(currSettings.PrefixURLTag) Then
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLTags, "tag")
            Else
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLTags, currSettings.PrefixURLTag.ToString())
            End If
            If String.IsNullOrEmpty(currSettings.PrefixURLCategory) Then
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLCategories, "category")
            Else
                objModules.UpdateModuleSetting(TabModuleId, SettingKeys.PrefixURLCategories, currSettings.PrefixURLCategory.ToString())
            End If

            objModules.UpdateModuleSetting(TabModuleId, "NeedsConvert", "False")
            objModules.UpdateModuleSetting(TabModuleId, "AFINSTALLED", "True")
            DataCache.CacheClear(String.Format(CacheKeys.MainSettings, ForumModuleId))
        End Function

    End Class
End Namespace

